<template>
	<view class="p-50 p-t-30 left">
		<text class="ts-40 tb wa left">
			<text class="tc-green">IMEI添加电池</text>
		</text>
		<br>
		<text class="ts-24 wa left m-t-5">
			<text class="tc-gray">绑定电池需要先完成实名认证</text>
		</text>
		<view class="form-item" style="margin-top: 55rpx;">
			<input placeholder-class="placeholder-color" class="form-input" type="text" v-model="imei" placeholder="填写电池的IMEI号"/>
			<view class="form-count" style="z-index:1000;"  @click="scanCode()">
				<image class="full-count" src="/static/img/sao.png" style="border-radius: 0;"></image>
			</view>
		</view>
		<view class="form-submit" @click="submit()">
			完成绑定
		</view>
		<view class="ts-30 wa tc" @click="realName()">
			<text class="tc-green">进行实名认证</text>
		</view>
	</view>
</template>

<script>
	export default {
		
		data() {
			return {
				css:{},
				submitDisabled:false,
				carsType:[
					{name:'冷藏车',value:'bank'},
					{name:'微货车',value:'alipay'},
					{name:'中面包车',value:'alipay'},
					{name:'小面包车',value:'alipay'},
					{name:'微型面包车',value:'alipay'},
					{name:'小货车',value:'alipay'},
				],
				imei:'',
				car_id:'',
			}
		},
		onLoad(options) {
			this.$xyfun.setNavBar(' ');
			this.car_id = options.car_id;
		},
		methods: {
			realName() {
				uni.navigateTo({
					url: `/pages/user/real`
				})
			},
			scanCode() {
				let that = this;
				uni.scanCode({
					success: function (res) {
						that.imei = res.result
						that.$xyfun.msg('扫码成功！');
					},
					fail:function(res){
						that.$xyfun.msg('扫码失败：'+res.errMsg);
					}
				});
			},
			submit() {
				this.$api.post({
					url: '/battery/battery/bindBattery',
					loadingTip:'加载中...',
					data: {
						imei: this.imei,
						car_id: this.car_id
					},
					success: res => {
						this.$xyfun.msg('添加成功');
						uni.reLaunch({
							url: '/pages/index?id='+this.car_id
						})
					}
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.form-submit {
		margin: 35rpx 0 50rpx;
		width: 649rpx;
    	height: 100rpx;
		border-radius: 15rpx;
		background-color: rgba(0,86,80,1);
		text-align: center;
		color: white;
		line-height: 95rpx;
		float: left;
	}
	.form-item {
		width: 100%;
		position: relative;
		margin-top: 35rpx;
		float: left;
		.form-input {
			width: 622rpx;
			height: 100rpx;
			border-radius: 15rpx;
			background-color: rgba(255,255,255,1);
			border: 1rpx solid rgba(111, 111, 111, 0.31);
			padding-left: 26rpx;
		}
		.placeholder-color {
			color: rgba(135,135,135,0.48);
		}
		.form-count {
			position: absolute;
			top: 30rpx;
			right: 30rpx;
			color: rgba(102,102,102,0.32);
			.full-count {
				width: 50rpx;
				height: 50rpx;
			}
		}
	}
</style>